<template>
	<div class="container">
		<Header title="转客"></Header>
		<div class="mint-cell mint-field">
			<div class="mint-cell-wrapper">
				<div class="mint-cell-title">
					<span class="mint-cell-text">客户姓名：</span>
				</div>
				<div class="mint-cell-value">
					<span class="mint-cell-text">{{customerInfo.name}}</span>
				</div>
			</div>	
		</div>
		<div class="mint-cell mint-field">
			<div class="mint-cell-wrapper">
				<div class="mint-cell-title">
					<span class="mint-cell-text">联系电话：</span>
				</div>
				<div class="mint-cell-value">
					<span class="mint-cell-text">{{customerInfo.mobile}}</span>
				</div>
			</div>	
		</div>
		<div class="mint-cell mint-field">
			<div class="mint-cell-wrapper">
				<div class="mint-cell-title">
					<span class="mint-cell-text">转到项目：</span>
				</div>
				<div class="mint-cell-value">
					<span class="mint-cell-text">{{customerInfo.premisesName}}</span>
				</div>
			</div>	
		</div>
		<div class="mint-cell mint-field is-textarea">
			<div class="mint-cell-wrapper">
				<div class="mint-cell-title">
					<span class="mint-cell-text">备注信息：</span>
				</div>
				<div class="mint-cell-value">
					<textarea placeholder="备注信息" rows="4" class="mint-field-core" v-model="remark"></textarea>
				</div>
			</div>
		</div>

		<div class="report-button">
			<mt-button size="large" type="danger" v-show="reportBtnShow" @click="ajaxToM2">转客</mt-button>
		</div>
	</div>
</template>
<script>
	import { MessageBox, Toast } from 'mint-ui';
	export default {
		data () {
		    return {
		    	cusPreId: this.$route.params.id,
		    	remark:'',//备注
		      	reportBtnShow: false,
		      	customerInfo:{}
		    }
		},
		computed: {
			
		},
		watch: {
		    
		},
		mounted() {
			this.initCustormerInfo();
		},
		methods :{
			initCustormerInfo() {
				var _self = this;
				var body = {};
				var params = {};
				params.cusPreId = _self.cusPreId;
				body.params = params;
				var url = _self.utilHelper.apiUrl + "/api/getCPToM2Info";
				_self.$http.post(url, body).then((response) => {
					var body = response.body;
					_self.customerInfo = body.resData;
					if(body.resData.isToM2 == "2"){
						var instance = Toast('该客户不符合转客要求，禁止转客');
					}else if((body.resData.customerStatus == "6" || body.resData.customerStatus == "7")
            			&& body.resData.isToM2 != "1"){
            			_self.reportBtnShow = true;
					}else{
						var instance = Toast('该客户已转客');
					}
				});
			},
			ajaxToM2() {
				var _self = this;
				_self.reportBtnShow = false;
                var body = {};
				var params = {};
				params.cusPreId = _self.cusPreId;
                body.params = params;
				var url = _self.utilHelper.apiUrl + "/api/customerToM2";
				_self.$http.post(url, body).then((response) => {
					var body = response.body.resData;
					if(body.result == "1"){
						if(body.failNum > 0){
							var instance = Toast(body.failList[0].errorMsg);
							_self.reportBtnShow = true;
						}else{
							var instance = Toast('转客成功');
						}
					}else{
						var instance = Toast('转客失败');
						_self.reportBtnShow = true;
					}
				});
			}
		}
	}
</script>
<style scoped>
	.mint-field .mint-cell-title{color: #000;}
	.mint-cell-value .sexBtn{width: 56px;height: 24px;border-radius: 4px;border:1px solid #cdcdcd;text-align: center;line-height: 22px;font-size: 12px;margin: 0 4px;}
	.mint-cell-value .sexBtn.active{border:1px solid #eb6100;color: #eb6100;background-color: #ffece0;}
	.sexBtn input{display: none;}
	.telEye{color: #ec6f26;position: absolute;right: 10px;display: inline-block;}
	.toggleTel .fa{margin-right: 6px;}
	.digital-input-box{position: absolute; opacity: 0.01;display: block; z-index: 50; left: 105px;width: 100%; top: 2px; height: 46px;}
	.digital-input{overflow: hidden;width: 100%;}
	.digital-input .digital-input-item{height: 48px;float: left;width: 9.09%;border-right: 1px dashed #d8d8d8;text-align: center;line-height: 48px;display: flex; justify-content: center;align-items: center;}
	.digital-input .digital-input-item:first-child{border-left:1px solid #d8d8d8;}
	.digital-input-item .fa{font-size: 12px;color: #999;}
	.mint-field.is-textarea .mint-cell-wrapper .mint-cell-text{position: absolute;top: 12px;}
	.report-button{padding: 0 10px;}
	.report-button .mint-button--danger{background-color: #eb6100;margin-top: 20px;}

	.selectCompany{width: 100%;}

	.digital-input:after{content:''; display:block; clear:both; visibility: hidden; overflow: hidden; font-size:0; height:0;}
</style>